//DHCOutPhFZLocHZPrint
var bottomFrame;
var topFrame;
var tblobj=document.getElementById("tDHCOutPhFZLocHZPrint");
var evtName;
var doneInit=0;
var focusat=null;
var SelectedRow = 0;
var pmiobj,pnameobj;
var stdateobj,enddateobj;
var phlobj,phwobj,locdescobj,phwdescobj,pydrobj,fydrobj,pynameobj,fynameobj;
var ctlocobj;
var BResetobj,BPrintobj;
var printobj;
function BodyLoadHandler() {
 
  BPrintobj=document.getElementById("BPrint");
  if (BPrintobj) BPrintobj.onclick=Print_click;
  
}

function SelectRowHandler()	{
	
	var eSrc=window.event.srcElement;
	if (eSrc.tagName=="IMG") eSrc=window.event.srcElement.parentElement;
	var eSrcAry=eSrc.id.split("z");
	var rowObj=getRow(eSrc);
	var selectrow=rowObj.rowIndex;
	if (!selectrow) return;
	SelectedRow = selectrow;

}


function Reset_click()
{
	location.href="websys.default.csp?WEBSYS.TCOMPONENT=DHCOutPhFZLocHZPrint";
 }

function Retrieve_click()
 {
  var stdate=document.getElementById("CDateSt").value
  var enddate=document.getElementById("CDateEnd").value
  var depcode=document.getElementById("CDepCode").value
  var tdoctor=document.getElementById("CDoctor").value
  var ctloc=document.getElementById("ctloc").value
  
 location.href="websys.default.csp?WEBSYS.TCOMPONENT=DHCOutPhFZLocHZPrint&CDateSt="+stdate+"&CDateEnd="+enddate+"&ctloc="+ctloc+"&CDepCode="+depcode+"&CDoctor="+tdoctor;

 
 }
 function Print_click(){
	 var objtbl=document.getElementById("tDHCOutPhFZLocHZPrint");

	 if (objtbl.rows.length==0) {return 0;}
	 var rows,Rrow,prt,name,pmino,printflag,inv;
	 rows=objtbl.rows.length-1
	 var path
     var Ls_orderitemtmp,RowN,i
      var getmethod=document.getElementById('getpath');
      if (getmethod) {var encmeth=getmethod.value} else {var encmeth=''};
      var path=cspRunServerMethod(encmeth)
      var datest=document.getElementById('stdate').value;
	  var dateend=document.getElementById('enddate').value;
	  var ordlocdesc=document.getElementById('OrdLocDesc').value;
	  var pagerow=35;
	  var xlApp,obook,osheet,xlsheet,xlBook
	    var paymoney
        var Template
        Template=path+"YFFZLOCHZ.xls"
        xlApp = new ActiveXObject("Excel.Application");
	    xlBook = xlApp.Workbooks.Add(Template);
	    xlsheet = xlBook.ActiveSheet 
	    xlsheet.cells(2,2).value=ordlocdesc
        xlsheet.cells(3,1).value=datest+t['to']+dateend
var pagenum
   if (Math.floor(rows/pagerow)==(rows/pagerow)){pagenum=Math.floor(rows/pagerow);}
	else {pagenum=Math.floor(rows/pagerow)+1;}  
var k,j,l,RowNum,count;
var  lastnum = rows-(pagenum-1)*pagerow 
    
 for (k=1;k<=pagenum;k++){
	 if (k==pagenum){RowNum=lastnum;} else { RowNum = pagerow;}
    //for (l=4;l<=pagerow+3;l++){for(j=1;j<=4;j++){xlsheet.Cells(l, j).value=""}}
    for(i=1;i<=RowNum;i++){
	  xlsheet.cells(4+i,1).value=document.getElementById("TPhDescz"+(i+(k-1)*pagerow)).innerText
	  xlsheet.cells(4+i,3).value=document.getElementById("TPhUomz"+(i+(k-1)*pagerow)).innerText
	  xlsheet.cells(4+i,4).value=document.getElementById("TPhggz"+(i+(k-1)*pagerow)).innerText
	  xlsheet.cells(4+i,5).value=document.getElementById("TPricez"+(i+(k-1)*pagerow)).innerText
	  xlsheet.cells(4+i,6).value=document.getElementById("TPhQtyz"+(i+(k-1)*pagerow)).innerText
	  xlsheet.cells(4+i,7).value=document.getElementById("TPhMoneyz"+(i+(k-1)*pagerow)).innerText
	  xlsheet.cells(4+i,8).value=document.getElementById("TFactoryz"+(i+(k-1)*pagerow)).innerText


		 }
    xlsheet.printout
 }   
	xlBook.Close(savechanges=false);
	xlApp=null;
	xlsheet=null

   }	   
function GetDropDep(value)
{
  var val=value.split("^") 
  var shdr=document.getElementById("CDepCode");
  shdr.value=val[1];
}
function GetDropDoctor(value)
{
  var val=value.split("^") 
  var shdr=document.getElementById("CDoctor");
  shdr.value=val[1];
}

document.body.onload = BodyLoadHandler;
